package me.zhengjie.modules.website.repository;

import me.zhengjie.modules.website.domain.CmInfos;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * @author system
 * @since 2025-01-14 17:56:04
 *
 */
@Repository
public interface CmInfosRepository extends JpaRepository<CmInfos, Long>, JpaSpecificationExecutor<CmInfos> {

    @Query("SELECT c FROM CmInfos c WHERE (:infoTitle IS NULL OR c.infoTitle LIKE %:infoTitle%) " +
            "AND (:infoType IS NULL OR c.infoType LIKE %:infoType%)")
    Page<CmInfos> findByConditions(@Param("infoTitle") String infoTitle,
                                   @Param("infoType") String infoType,
                                   Pageable pageable);

}
